﻿<cfsilent>
	<cfscript>
		
		stringAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		
		event.setArg("pageTitle", "学生调查问卷 - 在线调查设置向导 - 问卷预览");
		
		questionId = event.getArg("QSN");
		
		currentTab = event.getArg("TabID", "labPreview");
		
		passArgs = structNew();
		structInsert( passArgs, "QSN", questionId, true );
		
		sql = "	SELECT
					q.title,
					q.describe,
					q.grade_allowed,
					q.institute_allowed,
					q.gender_allowed
				FROM
					t_questionnaire q
				WHERE
					q.qsn_id = :questionId ";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "questionId", value = questionId, cfsqltype = "cf_sql_char");
		rs_quesEntity = queryObj.execute(sql = sql).getResult();
		
		
		sql = "	SELECT
					q.quo_id,q.question,q.measure
				FROM
					t_quota q
				WHERE
					q.qsn_id = :sheetId 
				ORDER BY
					q.quo_idx";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "sheetId", value = questionId, cfsqltype = "cf_sql_char");
		rs_quota = queryObj.execute(sql = sql).getResult();
		
		
		sql = "	SELECT
					r.stu_id
				FROM
					t_respondents r
				WHERE
					r.qsn_id = :questionId 
					AND
					r.state = 'U'
				ORDER BY
					r.stu_id";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "questionId", value = questionId, cfsqltype = "cf_sql_char");
		rs_studentIds = queryObj.execute(sql = sql).getResult();
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('voteList')#</cfoutput>"><i class="mrs img btnList"></i><span class="uiButtonText">调查问卷库</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 card"></i>在线调查问卷预览
				</h2>
			</div>
		</div>
	</div>
</div>

<!--- 加载导航菜单 --->
<!-- stepMenu-->
<cfoutput>#event.getArg("stepMenu")#</cfoutput>
<!--/stepMenu-->

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="findStudent">
				
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labPreview">class="active"</cfif> id="labPreview" tabTarget="Preview">预览</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
				
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
				
					});
					// -->
					//]]>
				</script>
				
				<div id="Preview" class="tabContent">
					
					<div class="noticeBlock">
						<div class="operation">
							<a class="uiButton" href="<cfoutput>#buildURL('voteSetupWizard', passArgs)#</cfoutput>"><i class="mrs img btnExecute"></i><span class="uiButtonText">修改题目</span></a>
							<a class="uiButton" href="<cfoutput>#buildURL('voteSetupWizardConfirm', passArgs)#</cfoutput>"><i class="mrs img btnDate"></i><span class="uiButtonText">时间及参与范围</span></a>
							<a class="uiButton" href="<cfoutput>#buildURL('voteSetupWizardPublish', passArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">发布</span></a>
						</div>
						<h3>最终效果预览</h3>
						<p><span class="img icon16x16 message"></span>将根据您的问题设置, 计算最终用户的问卷调查显示效果</p>
						<hr/>
					</div>
					
					<div class="systemNotice">
						<h3><cfoutput>#stringAdvice.XHTMLSafeFormat( rs_quesEntity.title )#</cfoutput></h3>
						<p class="mln"><span class="img icon16x16 message"></span><cfoutput>#stringAdvice.XHTMLSafeFormat( rs_quesEntity.describe )#</cfoutput></p>
					</div>
					
					<cfset row = 0 />
					<table class="UItable">
						<tr class="cellBorder">
							<td align="center" width="20">序</td>
							<td>问题</td>
							<td>选项</td>
						</tr>
                        <cfloop query="rs_quota">
							<cfset row++ />
							<tr class="cellBorder">
								<td align="center"><span class="number"><cfoutput>#row#</cfoutput></span></td>
								<td><cfoutput>#stringAdvice.XHTMLSafeFormat( rs_quota.question )#</cfoutput></td>
								<td width="250">
									<cfswitch expression="#rs_quota.measure#">
										<cfcase value="L1">
											<span class="stat on"></span> 是 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											<span class="stat off"></span> 否
										</cfcase>
										<cfcase value="L3">
											<span class="stat on"></span> 满意 &nbsp;&nbsp;
											<span class="stat off"></span> 基本满意 &nbsp;&nbsp;
											<span class="stat off"></span> 不满意 &nbsp;&nbsp;
										</cfcase>
										<cfcase value="L4">
											<span class="stat on"></span> 优秀 &nbsp;&nbsp;
											<span class="stat off"></span> 较好 &nbsp;&nbsp;
											<span class="stat off"></span> 普通 &nbsp;&nbsp;
											<span class="stat off"></span> 不好
										</cfcase>
									</cfswitch>
								</td>
							</tr>
						</cfloop>
					</table>
					
					<div class="systemNotice">
						<h3>调查范围</h3>
						<cfif rs_quesEntity.grade_allowed eq "NOP" and rs_quesEntity.institute_allowed eq "NOP" and rs_quesEntity.gender_allowed eq "NOP">
							<p>
								自定义: 学生 <em><cfoutput>#rs_studentIds.recordCount#</cfoutput></em> 人
							</p>
							<cfelse>
							<p>
								年级: 
								<cfif rs_quesEntity.grade_allowed eq "ALL">
									全部
									<cfelse>
									<em><cfoutput>#rs_quesEntity.grade_allowed#</cfoutput></em>
								</cfif>
							</p>
							<p>
								学院: 
								<cfif rs_quesEntity.institute_allowed eq "ALL">
									全部
									<cfelse>
                                    <cfset sql = "SELECT t.institute_short FROM t_institute t WHERE t.institute_id IN (:depIds ) ORDER BY t.institute_short"/>
                                    <cfset queryObj = new Query(datasource = application.dnsSlave) />
                                    <cfset queryObj.addParam(name = "depIds", value = rs_quesEntity.institute_allowed, cfsqltype = "cf_sql_varchar", list = true)/>
                                    <cfset rs_instituteNames = queryObj.execute(sql = sql).getResult() />
									<cfoutput>#valueList(rs_instituteNames.institute_short,", ")#</cfoutput>
								</cfif>
							</p>
							<p>
								性别: 
								<cfif rs_quesEntity.gender_allowed eq "ALL">
									全部
									<cfelseif rs_quesEntity.gender_allowed eq "1">
									男生
									<cfelseif rs_quesEntity.gender_allowed eq "2">
									女生
								</cfif>
							</p>
						</cfif>
					</div>
					
				</div>
				
			</div>
		</li>
	</ul>
</div>